The GO Workshop by Delio D'Anna Andrew Hayes Sam Hennessy Jeremy Leasor 
Gobin Sougrakpam and Dániel Szabó

The GO Workshop by Delio D'Anna Andrew Hayes Sam Hennessy Jeremy Leasor 
Gobin Sougrakpam and Dániel Szabó

Author:Delio D'Anna, Andrew Hayes, Sam Hennessy, Jeremy Leasor,
Gobin Sougrakpam, and Dániel Szabó
Language: eng
Format: epub
Publisher: Packt Publishing Pvt. Ltd.
Published: 2020-12-28T00:00:00+00:00


Figure 10.3: Transaction deadline not met

When we meet the deadline, it looks like this:

Figure 10.4: Transaction deadline met

Let's dissect our example. First, we define a deadline for the transaction with the time.Duration() variable. In my experience, the Millisecond resolution is optimal; however, it does take some time to get used to calculating it. Feel free to use whichever resolution you prefer. We mark the beginning with the Start variable, do some calculations, and mark the completion with the End variable. The magic happens after this. We would like to calculate the difference between the deadline and the transaction duration, but we cannot do it directly. We need to convert the Duration value to Transaction time. This is done the same way when we created our deadline. We simply use the Nanosecond resolution, which is the lowest resolution we should go to. However, in this case, you can use the resolution you would like. After conversion, we can easily compare and decide whether the transaction is fine or not.

Now, let's see how we can manipulate time.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.